home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / libs / patchlib539.lha / patchlib / include / patch.h < prev    next >
C/C++ Source or Header  |  1996-12-07  |  8KB  |  196 lines

  1. #ifndef LIBRARIES_PATCH_H
  2. #define LIBRARIES_PATCH_H
  3. /*****************************************************************************/
  4. /*
  5. **    Filename:    libraries/patch.h
  6. **    Release:    5.0
  7. **    Date:        12.10.96
  8. **
  9. **    definition of patch.library public structures and returncodes
  10. **
  11. **    (C) Copyright 1993-96 Stefan Fuchs
  12. **    All Rights Reserved
  13. */
  14. /*****************************************************************************/
  15.  
  16. #ifndef    EXEC_TYPES_H
  17. #include <exec/types.h>
  18. #endif
  19.  
  20. #ifndef    EXEC_LISTS_H
  21. #include    <exec/lists.h>
  22. #endif    /* EXEC_LISTS_H */
  23.  
  24. #ifndef    EXEC_LIBRARIES_H
  25. #include    <exec/libraries.h>
  26. #endif    /* EXEC_LIBRARIES_H */
  27.  
  28. #ifndef    EXEC_SEMAPHORES_H
  29. #include    <exec/semaphores.h>
  30. #endif    /* EXEC_SEMAPHORES_H */
  31.  
  32.  
  33. /*----------------------------------------------------------------------------*/
  34. /* ErrorCodes */
  35. #define PATERR_Ok        0    /* Everything Ok                */
  36. #define PATERR_PatchInUse    1    /* Patch Usecount <> 0                */
  37. #define PATERR_InvalidHandle    2    /* Pointer to patch is not (no longer) valid    */
  38. #define PATERR_OutOfMem        3    /* Out of memory                */
  39. #define PATERR_OpenLib        4    /* Failed to open requested library        */
  40. #define PATERR_FuncNotStd    5    /* Function to patch is not in the standard format */
  41. #define PATERR_PatchInstalled    6    /* Can't remove patch because another program has  */
  42.                     /* installed a non-patch.library patch later       */
  43. #define PATERR_InvalidTags    7    /* There was an error in the combination of the specified Tags */
  44. #define PATERR_OpenDev        8    /* Failed to open requested device */
  45. #define PATERR_NoTaskList    9    /* PATT_AddTask... or PATT_RemTask... was specified for a patch, */
  46.                     /* which had no PATT_CreateTaskList set */
  47. #define PATERR_TaskListExists    10    /* PATT_CreateTaskList was specified, but there already exists a TaskList */
  48. #define PATERR_InvalidTaskList    11    /* PATT_CreateTaskList was specified with a wrong parameter */
  49. #define PATERR_PatchUnnamed    12    /* PATT_PatchName with GetPatch was specified, for a patch without an IDString */
  50. #define PATERR_NoSemaphore    13    /* Could not allocate semaphore */
  51.  
  52. #define PATERR_KickTooOld    14    /* Kickstart version is too old for this function */
  53. #define PATERR_InvalidPattern    15    /* Pattern passed via PATT_AddTaskPattern is not valid */
  54. #define PATERR_Restricted    16    /* Certain tags/features may not be used when patching certain functions */
  55.  
  56. /*----------------------------------------------------------------------------*/
  57. struct PatchNotifyMessage {
  58.     struct Message pnm_ExecMessage;
  59.     ULONG  pnm_Class;
  60.     UWORD  pnm_Code;
  61.     APTR   pnm_Object;
  62. };
  63.  
  64. /*----------------------------------------------------------------------------*/
  65. #define PATCHNOTIFY_CLASS    0x50000000
  66. /*----------------------------------------------------------------------------*/
  67. /*Notification codes (pnm_Code) (ignore messages with other codes): */
  68. #define PATCOD_PatchInstalled    1    /* new patch has been added */
  69. #define PATCOD_PatchRemoved    2    /* a patch has been removed */
  70. #define PATCOD_PatchChanged    3    /* attributes of a patch have been changed */
  71.  
  72. /*----------------------------------------------------------------------------*/
  73. struct PatchXResult {        /* Use PatchAlloc(PS_TYPE_XRESULT) to allocate this */
  74.     struct Node pxr_Node;    /* Reserved */
  75.     ULONG  pxr_RegPattern;    /* Which of the following register fields are used */
  76.     ULONG  pxr_RegD0;
  77.     ULONG  pxr_RegD1;
  78.     ULONG  pxr_RegD2;
  79.     ULONG  pxr_RegD3;
  80.     ULONG  pxr_RegD4;
  81.     ULONG  pxr_RegD5;
  82.     ULONG  pxr_RegD6;
  83.     ULONG  pxr_RegD7;
  84.     ULONG  pxr_RegA0;
  85.     ULONG  pxr_RegA1;
  86.     ULONG  pxr_RegA2;
  87.     ULONG  pxr_RegA3;
  88.     ULONG  pxr_RegA4;
  89.     ULONG  pxr_RegA5;
  90.     ULONG  pxr_RegA6;
  91.     UWORD  pxr_FlowControl;    /* What patches follow this one (see below) */
  92. };
  93. /*----------------------------------------------------------------------------*/
  94. /* Valid values for pxr_FlowControl: */
  95. #define PATFC_Normal    0    /* No change in the sequence of patchcodes */
  96. #define PATFC_FallBack    1    /* Use original function (only valid, if PATT_Priority is NULL) */
  97.  
  98. /*----------------------------------------------------------------------------*/
  99. /* Register definitions for the obsolete PATT_SaveRegisters and pxr_RegPattern */
  100.  
  101. #define PATREG_D0    0x8000
  102. #define PATREG_D1    0x4000
  103. #define PATREG_D2    0x2000
  104. #define PATREG_D3    0x1000
  105. #define PATREG_D4    0x0800
  106. #define PATREG_D5    0x0400
  107. #define PATREG_D6    0x0200
  108. #define PATREG_D7    0x0100
  109. #define PATREG_A0    0x0080
  110. #define PATREG_A1    0x0040
  111. #define PATREG_A2    0x0020
  112. #define PATREG_A3    0x0010
  113. #define PATREG_A4    0x0008
  114. #define PATREG_A5    0x0004
  115. #define PATREG_A6    0x0002
  116.  
  117. /*----------------------------------------------------------------------------*/
  118. #define    PatchName "patch.library"
  119. /*----------------------------------------------------------------------------*/
  120.  
  121.  
  122.  
  123.  
  124. /*------------------------------------------------------------------------------*/
  125. /*------------------------------------------------------------------------------*/
  126. /* The following structures are not needed by normal patch.library applications */
  127. /*------------------------------------------------------------------------------*/
  128. /*------------------------------------------------------------------------------*/
  129. struct PatchBase
  130. {
  131.     struct Library LibNode;
  132.     UBYTE PB_Flags;                    /* see below */
  133.     UBYTE PB_reserved1;
  134.     ULONG PB_private1;
  135.     struct SignalSemaphore    PB_Semaphore;        /* Semaphore to protect MasterPatchList */
  136.     struct List        PB_MasterPatchHeader;    /* Listheader Structure for MasterPatch */
  137.  
  138.     /* ... */
  139.  
  140. };
  141. /* PB_Flags: */
  142.  
  143. #define PBF_CheckPC    (1<<0)            /* If TRUE: Enable safe removal of patches! */
  144.                     /* Patch.library will use a hack, which */
  145.                     /* is highly dependent on OS versions and installed */
  146.                     /* processors and may therefore not work with */
  147.                     /* certain configurations */
  148.                     /* It's unlikely to crash the machine though */
  149.                     /* New with V5, default: FALSE */
  150.  
  151. /*----------------------------------------------------------------------------*/
  152. /* Before accessing this structure, make sure MPS_Node.ln_Type is PS_TYPE_MASTER */
  153.  
  154. struct MasterPatch            /* This structure is READONLY */
  155. {
  156. struct    Node    MPS_Node;        /* ln_Name may contain a pointer to the name of the patched library */
  157.                     /* To compensate the loss of a valid librarybase */
  158.                     /* ln_Name is now (V4) guaranteed to contain a valid name */
  159.                     /* This may however be a library, device or resource name */
  160.     UWORD    MPS_Flags;        /* no public flags defined */
  161. struct    MinList    MPS_PatchHeader;    /* Listheader Structure for Patch structures */
  162.     APTR    MPS_Private01;        /* This pointer, up to V3 known as MPS_PatchedLibraryBase */
  163.                     /* has been renamed, because with the introduction of the */
  164.                     /* PatchSupervisor it may or may not contain a valid */
  165.                     /* librarybase, it may even contain 0. */
  166.     UWORD    MPS_PatchedLVO;        /* Library Vector Offset in patched library */
  167.  
  168.     /* ... */
  169.  
  170. };
  171.  
  172. /*----------------------------------------------------------------------------*/
  173. /* Before accessing this structure, make sure PS_Node.ln_Type is either PS_TYPE_USER or PS_TYPE_SYSTEM */
  174. /* Make sure your program can handle lists, that do not contain any nodes of */
  175. /* PS_TYPE_USER or PS_TYPE_SYSTEM */
  176.  
  177. struct    Patch            /* This structure is READONLY */
  178. {
  179. struct    Node    PS_Node;    /* ln_Name may contain a pointer to the name of the patch */
  180.     UWORD    PS_Flags;    /* no public flags defined */
  181.  
  182.     /* ... */
  183.  
  184. };
  185.  
  186. /*----------------------------------------------------------------------------*/
  187. /* public types for patch and masterpatch structures: */
  188. #define PS_TYPE_MASTER    1    /* node is MasterPatch structure */
  189. #define PS_TYPE_USER    2    /* node was installed by an Application using the library interface */
  190. #define PS_TYPE_SYSTEM    3    /* node was installed by the support program PatchSetFunc */
  191. #define PS_TYPE_XRESULT     30    /* this struct is an PatchXResult structure */
  192.  
  193.  
  194.  
  195. #endif    /* LIBRARIES_PATCH_H */
  196.